package com.auxgroup.smarthome.openapi.requestbody;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;
import java.util.List;

/**
 * 根据 Did 绑定设备 的请求信息
 */
public class BindDidDeviceInfo {

    private String did ;
    private String passcode;
    private String remark;

    @JSONField(name = "dev_alias")
    private String devAlias;

    @JSONField(name = "set_owner")
    private int setOwner;

    private String mdid;

    public BindDidDeviceInfo() {
    }

    public BindDidDeviceInfo(String did, String passcode) {
        this.did = did;
        this.passcode = passcode;
    }

    public BindDidDeviceInfo(String did, String passcode, String remark, String devAlias, String mdid) {
        this.did = did;
        this.passcode = passcode;
        this.remark = remark;
        this.devAlias = devAlias;
//        this.setOwner = setOwner;
        this.mdid = mdid;
    }

    public String getDid() {
        return did;
    }

    public void setDid(String did) {
        this.did = did;
    }

    public String getPasscode() {
        return passcode;
    }

    public void setPasscode(String passcode) {
        this.passcode = passcode;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getDevAlias() {
        return devAlias;
    }

    public void setDevAlias(String devAlias) {
        this.devAlias = devAlias;
    }

    public int getSetOwner() {
        return setOwner;
    }

    public void setSetOwner(int setOwner) {
        this.setOwner = setOwner;
    }

    public String getMdid() {
        return mdid;
    }

    public void setMdid(String mdid) {
        this.mdid = mdid;
    }


    public String toJsonString()
    {
        JSONObject device = new JSONObject();
        device.put("did",did);
        device.put("passcode",passcode);
        device.put("remark",remark);
        device.put("dev_alias",devAlias);
        device.put("set_owner",setOwner);
        List<JSONObject> devices = new ArrayList<>();
        devices.add(device);
        JSONObject json = new JSONObject();
        json.put("devices",devices);
        json.put("mdid",mdid);
        return json.toJSONString();
    }

}
